﻿{include file = $smarty.const.APPLICATION_PATH|cat:"/application/views/registerheader.html"}
{literal}
<script type="text/javascript">
    function change_code(){
        var img = document.getElementById('login_code_img');
        img.src = '/login/code/rand/' + Math.random();
    };

    $(function(){
        var Obmobile = $("input[name=mobile]");
        var Obcode = $("input[name=code]");

        $('.lcl_btn').click(function(){
            if(validatemobile(Obmobile)==false || ncodeEmpty(Obcode) ==false){
                return false;
            }else{
                document.myForm.submit();
            }
        });

        Obmobile.blur(function(){
            validatemobile(Obmobile);
        });

        Obcode.blur(function(){
            ncodeEmpty(Obcode);
        });

    });

    function isExistMobile(mobile){
        $.ajax({
            url:'/register/isExistMobile',
            data:{mobile:mobile},
            async:false,
            type:'POST',
            success:function(data){
                var data = eval("("+data+")");
                var code = data.code;
                var msg = data.msg;
                if(code == 38){
                    result =  false;
                }else{
                    $(".phonemsg").html("");
                    result= true;
                }
            },
            dataType:'text'
        });

        return result;
    }

    function validatemobile(mobile)
    {
        var mobile = mobile.val();
        var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;

        if(mobile.length==0)
        {
            $(".phonemsg").html("请输入手机号码！");
            return false;
        }else if(mobile.length!=11)
        {
            $(".phonemsg").html("请输入有效的手机号码！");
            return false;
        }else if(!myreg.test(mobile))
        {
            $(".phonemsg").html("请输入有效的手机号码！");
            return false;
        }else if(isExistMobile(mobile)  ==false) {
            $(".phonemsg").html("该手机号不存在！");
            return false;
        }else{
            $(".phonemsg").html("");
            return true;
        }
    }

    function ncodeEmpty(obj){
        Value = obj.val();
        var mobile = $("input[name=mobile]").val();
        if(Value==''){
            $('.msg').html("请输入验证码！");
            return false;
        }else{
            var code = Value;
            $.ajax({
                url:'/register/confirmcode',
                data:{code:code,mobile:mobile},
                async:false,
                type:'POST',
                success:function(data){
                    var data = eval("("+data+")");
                    var code = data.code;
                    var msg = data.msg;
                    var data = data.data;
                    if(code == 8){
                        $(".msg").html("");
                        $("input[name=codetime]").val(data.vcode);
                        result =  true;
                    }else{
                        $(".msg").html(msg);
                        result= false;
                    }
                },
                dataType:'text'
            });
            return result;
        }
    }
</script>
<style>.technological_process li{width:200px;}</style>
{/literal}


<div class="clearfix"></div>

<div class="login_wrap">
	<div class="register_wrap">
        <ul class="technological_process">
            <li class="curr"><i>1</i>填写手机号码</li>
            <li><i>2</i>验证手机号码</li>
            <li><i>3</i>修改密码</li>
            <li><i>4</i>修改成功</li>
        </ul>
        
        <ul class="tp_cp">
            <form method="post" target="_self" id="myForm" name="myForm"  action="/findpwd/steptow">
                <input class="login-text" type="hidden"  name="codetime"/>
            <li><span>手机号码：</span><input class="lcl_text" name="mobile" type="text"/><span class="phonemsg orange pl10"></span></li>
            <li><span class="fl mt8">　验证码：</span><input class="lcl_text wid18 fl" type="text" name="code"  placeholder="请输入验证码"/><img src="/login/code"  id="login_code_img" onclick="change_code()" width="135" height="36"  class="ml10 cp fl"/><span class="msg orange pl10 fl pt10"></span></li>
            <li class="tp_cp_server"><input class="lcl_btn" type="button" value="下一步"/></li>
            </form>
        </ul>
        
    </div>
</div>


{include file = $smarty.const.APPLICATION_PATH|cat:"/application/views/registerfooter.html"}
